<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:form="http://java.sun.com/jsf/composite/components/form"
	xmlns:sec="http://www.springframework.org/security/tags"
	template="/templates/include/securedmain.xhtml">

	<ui:define name="content">
		<h:form id="form">
			<p:growl id="growl" showDetail="true" sticky="false" />
			<p:dataTable var="objClass"
				value="#{objectClassTableBean.objectDataModel}" paginator="true"
				rows="10" filteredValue="#{objectClassTableBean.filteredObjects}"
				selection="#{objectClassTableBean.selectedObjects}"
				id="objectsTable">

				<!-- This is a workaround for proper multiselection (guys from prime are loosers) -->
				<p:ajax event="toggleSelect" update="@this" process="@this" />
				<p:ajax event="rowSelectCheckbox" update="@this" />
				<p:ajax event="rowUnselectCheckbox" update="@this" />
				<p:ajax event="rowSelect" update="@this" />
				<p:ajax event="rowUnselect" update="@this" />


				<!-- 				<p:ajax event="rowSelect" update=":form:display" -->
				<!-- 					oncomplete="objectDialog.show()" /> -->

				<p:column selectionMode="multiple" style="width:2%" />

				<f:facet name="header">
					#{msg['menu.main.objectmanagement']}
				</f:facet>

				<p:column headerText="#{msg['properties.objectclass.name']}"
					id="objcl" filterBy="#{objClass.name}">

					<h:outputText value="#{objClass.name}" />
				</p:column>

				<p:column headerText="#{msg['properties.objectclass.pickable']}"
					id="objPick">
					<p:selectBooleanCheckbox value="#{objClass.pickable}"
						disabled="true" />
				</p:column>

				<p:column headerText="#{msg['properties.objectclass.returnable']}"
					id="objRet">
					<p:selectBooleanCheckbox value="#{objClass.returnable}"
						disabled="true">
					</p:selectBooleanCheckbox>
				</p:column>


				<p:column headerText="#{msg['view.actions']}" id="editAcs">
					<sec:authorize ifAnyGranted="ROLE_ADMIN">
						<p:button id="editButton" outcome="/admin/edit/editobjectclass"
							title="#{msg['view.actions.edit']}" icon="ui-icon-pencil"
							update="@form" ajax="false">
							<f:param name="id" value="#{objClass.id}" />
						</p:button>
					</sec:authorize>


					<p:button id="viewButton" outcome="view/viewobjectclass"
						title="#{msg['view.actions.view']}" icon="ui-icon-search"
						update="@form" ajax="false">
						<f:param name="id" value="#{objClass.id}" />
					</p:button>
				</p:column>

				<f:facet name="footer">
					<sec:authorize ifAnyGranted="ROLE_ADMIN">
						<p:commandButton id="showDialogButton"
							value="#{msg['view.actions.delete']}" icon="ui-icon-trash"
							onclick="confirmation.show()" type="button" />
						<p:button id="createObjectButton"
							value="#{msg['view.actions.create']}" icon="ui-icon-circle-plus"
							outcome="/admin/edit/createobjectclass" />
					</sec:authorize>

				</f:facet>
			</p:dataTable>
		</h:form>
		<p:confirmDialog id="confirmDialog" appendToBody="true"
			message="#{msg['view.actions.delete.label']}"
			header="#{msg['view.actions.delete']}" severity="alert"
			widgetVar="confirmation">

			<!-- update="messages" -->
			<p:commandButton id="confirm"
				value="#{msg['view.actions.button.commit']}"
				oncomplete="confirmation.hide()"
				actionListener="#{objectClassTableBean.deleteSelectedObjects}"
				update="form" />
			<p:commandButton id="decline"
				value="#{msg['view.actions.button.cancel']}"
				onclick="confirmation.hide()" type="button" />
		</p:confirmDialog>

	</ui:define>
</ui:composition>
